import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import Refast, { LogicRender } from 'refast';
import { Component } from 'react';
import { render } from 'react-dom';
import FastClick from 'fastclick';
import { Toast, Dialog } from 'saltui';

import { isDev } from 'variables';
/*import PageIndex from 'pages/index';*/

/*import PageMeetingHome from 'pages/meeting/home';*/
import PageMeetingBoardRoomView from 'pages/meeting/boardRoomview';
import PageMeetingMeeting from 'pages/meeting/meetingList';
import PageMeetingTaskMineList from 'pages/meeting/taskMineList';
import PageMeetingDetails from 'pages/meeting/meetingDetails';
import PageMeetingMyMeetingDetails from 'pages/meeting/myMeetingDetails';
import PageMyCycleMeeting from 'pages/meeting/myCycleMeeting';
import PageMeetingNotice from 'pages/meeting/meetingNotice';
import PageMeetingMemo from 'pages/meeting/memo';
import PageMeetingApprove from 'pages/meeting/approve';
import PageMeetingAdd from 'pages/meeting/add';
import PageMeetingAddNotice from 'pages/meeting/addNotice';
import PageMeetingCancelReason from 'pages/meeting/cancelReason';
import PageMeetingMeetingMemo from 'pages/meeting/meetingMemo';
import PageMeetingTransmitMemo from 'pages/meeting/memoTransmit';
import PageMeetingLeaveReason from 'pages/meeting/leaveReason';
import PageMeetingTurnover from 'pages/meeting/turnover';
import PageMeetingChangeMemoUser from 'pages/meeting/changeMemoUser';
import SendRemind from 'pages/meeting/sendRemind';
import PageMeetingRebackReason from 'pages/meeting/rebackReason';
import PageMeetingJoinList from 'pages/meeting/joinList';
import PageMeetingBoardRoom from 'pages/meeting/boardRoom';
import PageMeetingTaskList from 'pages/meeting/taskList';
import PageMeetingTaskAdd from 'pages/meeting/taskAdd';
import PageMeetingTaskView from 'pages/meeting/taskView';
import PageMeetingSignInfo from 'pages/meeting/positionSign';
import PageMeetingQrcodeSign from 'pages/meeting/qrcodeSign';
import PageMeetingQS from 'pages/meeting/meetingQS';


import PageMeetingRoomBpmList from 'pages/meeting/roomBpmList';
import PageMeetingProcessDetail from 'pages/meeting/processDetails';
import PageMeetingBatchBpm from 'pages/meeting/meetingBatchSubmit';
import ApplyBoardroomList from 'pages/meeting/applyBoardroomList';
import SelectBoardroom from 'pages/meeting/selectBoardroom';
import ReceiptStatistics from 'pages/meeting/receiptStatistics';
import QrCodeRedirect from 'pages/meeting/qrCodeRedirect';

import HelpIndex from 'pages/help/list';
import HelpShenpi from 'pages/help/shenpi';
import HelpShouwen from 'pages/help/shouwen';
import HelpAdministrator from 'pages/help/administrator';
import HelpMenageInfo from 'pages/help/menageInfo';
import HelpRemind from 'pages/help/remind';
import HelpTaskInfo from 'pages/help/taskInfo';
import HelpMeetingProcess from 'pages/help/meetingProcess';

/*import HelpAboutOne from 'pages/meeting/aboutOne';
import HelpAboutTwo from 'pages/meeting/aboutOne/aboutTwo';
import HelpAboutThree from 'pages/meeting/aboutOne/aboutThree';
import HelpAboutFour from 'pages/meeting/aboutOne/aboutFour';
import HelpAboutFive from 'pages/meeting/aboutOne/aboutFive';
import HelpAboutSix from 'pages/meeting/aboutOne/aboutSix';
import HelpAboutSeven from 'pages/meeting/aboutOne/aboutSeven';
import HelpAboutEight from 'pages/meeting/aboutOne/aboutEight';
import HelpAboutNine from 'pages/meeting/aboutOne/aboutNine';
import HelpAboutTen from 'pages/meeting/aboutOne/aboutTen';
import HelpAboutEleven from 'pages/meeting/aboutOne/aboutEleven';
import HelpAboutTwelve from 'pages/meeting/aboutOne/aboutTwelve';
import HelpAboutThirteen from 'pages/meeting/aboutOne/aboutThirteen';
import HelpAboutFourteen from 'pages/meeting/aboutOne/aboutFourteen';
import HelpAboutFifteen from 'pages/meeting/aboutOne/aboutFifteen';*/

import DB from 'db';
import './app.less';

const customHistory = hashHistory;

if (isDev && window.chrome && window.chrome.webstore) { // This is a Chrome only hack
  // see https://github.com/livereload/livereload-extensions/issues/26
  setInterval(() => {
    document.body.focus();
  }, 200);
}

// bind fastclick
FastClick.attach(document.body);

// 这里使用 use 来配置 Refast
// Refast 文档 https://recore.github.io/refast-docs/
Refast.use('fn', {
  toast: Toast,
  dialog: Dialog,
  DB,
  history: customHistory,
});

const Loading = () => <div className="kuma-loading" />;
const Empty = () => <div>暂无数据</div>;

// 修改 LogicRender 增加默认配置
// 用来自定义Loading和Empty的样式
LogicRender.defaultProps.Empty = Empty;
LogicRender.defaultProps.Loading = Loading;

class App extends Component {
  render() {
    return (
      <div>
        {this.props.children}
      </div>
    );
  }
}

  render(
    <Router history={customHistory}>
      <Route name="app" path="/" component={App}>
        <IndexRoute component={PageMeetingNotice}/>
        {/*<Route path="meeting/home" component={PageMeetingHome} />*/}
        <Route path="meeting/boardRoomview" component={PageMeetingBoardRoomView}/>
        <Route path="meeting/qrCodeRedirect/:id" component={QrCodeRedirect}/>
        <Route path="meeting/meetingList" component={PageMeetingMeeting}/>
        <Route path="meeting/taskMineList" component={PageMeetingTaskMineList}/>
        <Route path="meeting/meetingDetails/:id(/:type)(/:message)" component={PageMeetingDetails}/>
        <Route path="meeting/meetingQS/:id" component={PageMeetingQS}/>
        <Route path="meeting/myMeetingDetails/:id/:comefrom(/:type)(/:message)" component={PageMeetingMyMeetingDetails}/>
        <Route path="meeting/myCycleMeeting/:id" component={PageMyCycleMeeting}/>
        <Route path="meeting/receiptStatistics/:id" component={ReceiptStatistics}/>
        <Route path="meeting/meetingNotice" component={PageMeetingNotice}/>
        <Route path="meeting/memo" component={PageMeetingMemo}/>
        <Route path="meeting/applyBoardroomList" component={ApplyBoardroomList}/>
        <Route path="meeting/selectBoardroom/:isCycleBoardroom" component={SelectBoardroom}/>
        <Route path="meeting/approve(/:activeItem)" component={PageMeetingApprove}/>
        <Route path="meeting/addNotice(/:view)(/:id)(/:boardRoomId)" component={PageMeetingAddNotice}/>
        <Route path="meeting/add(/:view)(/:id)(/:boardRoomId)(/:startTime/:endTime)" component={PageMeetingAdd}/>
        <Route path="meeting/boardRoom/:id(/:currentDate)" component={PageMeetingBoardRoom}/>
        <Route path="meeting/cancelReason/:id" component={PageMeetingCancelReason}/>
        <Route path="meeting/meetingMemo/:id(/:memoId/:type)(/:message)" component={PageMeetingMeetingMemo}/>
        <Route path="meeting/leaveReason/:id" component={PageMeetingLeaveReason}/>
        <Route path="meeting/turnover/:id/:meetingId" component={PageMeetingTurnover}/>
        <Route path="meeting/changeMemoUser/:id/:memoUser" component={PageMeetingChangeMemoUser}/>
        <Route path="meeting/memoTransmit/:memoId" component={PageMeetingTransmitMemo}/>
        <Route path="meeting/sendRemind/:meetingId/:userArray" component={SendRemind}/>
        <Route path="meeting/rebackReason/:id/:noticeId(/:timeStamp)" component={PageMeetingRebackReason}/>
        <Route path="meeting/joinList/:id(/:sign/:type/:myType/:signedDateTime/:isEmceeUser/:isCreatedUser)"
               component={PageMeetingJoinList}/>
        <Route path="meeting/taskList/:applyRecordId" component={PageMeetingTaskList}/>
        <Route path="meeting/taskAdd/:applyRecordId(/:id)" component={PageMeetingTaskAdd}/>
        <Route path="meeting/taskView/:id/:applyRecordId/:view(/:message)" component={PageMeetingTaskView}/>
        <Route path="meeting/positionSign/:applyRecordId" component={PageMeetingSignInfo}/>
        <Route path="meeting/qrcodeSign/:id" component={PageMeetingQrcodeSign}/>
        <Route path="meeting/roomBpmList" component={PageMeetingRoomBpmList}/>
        <Route path="process/processDetails/:taskId/:formId/:dataId/:listType/:isPush/:processInstanceId/:module(/:category)"
               component={PageMeetingProcessDetail}/>
        <Route path="meeting/meetingBatchSubmit/:taskIds/:processInstanceIds/:operate/:code/:hasCommentField/:urgent/:isStart" component={PageMeetingBatchBpm} />

        <Route path="help/help_index" component={HelpIndex}/>
        <Route path="help/help_shenpi" component={HelpShenpi}/>
        <Route path="help/help_shouwen" component={HelpShouwen}/>
        <Route path="help/help_administrator" component={HelpAdministrator}/>
        <Route path="help/menageInfo" component={HelpMenageInfo}/>
        <Route path="help/remind" component={HelpRemind}/>
        <Route path="help/taskInfo" component={HelpTaskInfo}/>
        <Route path="help/meetingProcess" component={HelpMeetingProcess}/>

        {/*<Route path="demo/aboutOne" component={HelpAboutOne} />
      <Route path="demo/aboutTwo" component={HelpAboutTwo} />
      <Route path="demo/aboutThree" component={HelpAboutThree} />
      <Route path="demo/aboutFour" component={HelpAboutFour} />
      <Route path="demo/aboutFive" component={HelpAboutFive} />
      <Route path="demo/aboutSix" component={HelpAboutSix} />
      <Route path="demo/aboutSeven" component={HelpAboutSeven} />
      <Route path="demo/aboutEight" component={HelpAboutEight} />
      <Route path="demo/aboutNine" component={HelpAboutNine} />
      <Route path="demo/aboutTen" component={HelpAboutTen} />
      <Route path="demo/aboutEleven" component={HelpAboutEleven} />
      <Route path="demo/aboutTwelve" component={HelpAboutTwelve} />
      <Route path="demo/aboutThirteen" component={HelpAboutThirteen} />
      <Route path="demo/aboutFourteen" component={HelpAboutFourteen} />
      <Route path="demo/aboutFifteen" component={HelpAboutFifteen} />*/}

      </Route>
    </Router>,
    document.getElementById('App'),
  );
